from rest_framework_jwt.settings import api_settings

def get_jwt_token(user):
    """
    生成jwt的token用于状态保持
    :param user: 用户对象
    :return:　token
    """
    jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
    jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
    pay_load = jwt_payload_handler(user)
    token = jwt_encode_handler(pay_load)

    return token